<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="java.util.*"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<HTML>
<HEAD>
	<TITLE>left</TITLE>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=9;"> 
	
	<link rel="stylesheet" href="${path }/resource/zTree/css/demo.css" type="text/css">
	<link rel="stylesheet" href="${path }/resource/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<script type="text/javascript" src="${path }/resource/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="${path }/resource/zTree/js/jquery.ztree.core.js"></script>
	<script type="text/javascript" src="${path }/resource/zTree/js/jquery.ztree.excheck.js"></script>
	<script type="text/javascript" src="${path }/resource/zTree/js/jquery.ztree.exedit.js"></script>
	<link rel="stylesheet" href="${path }/resource/bootstrap/css/bootstrap.min.css" />
	<link rel="stylesheet" href="${path }/resource/bootstrap/css/bootstrap.addtabs.css" />
	<script type="text/javascript" src="${path }/resource/bootstrap/js/bootstrap.addtabs.js"></script>
	<script type="text/javascript" src="${path }/resource/bootstrap/js/bootstrap.min.js"></script>
	<SCRIPT type="text/javascript">
	var zTree;
	//创建树型结构
	function createTree() {
		var setting = {
			edit: {
				enable: true,
				showRemoveBtn: false,
				showRenameBtn: false
			},
			  async: {
		            enable: true,//设置是否异步加载
		            url:"${path}/user/fun/myfun"
		        },
			data: {
				simpleData: {
					enable: true,
					pIdKey: "pId",
	                idKey: "id"
				},
				key: {
                    checked: "CHECKED",
                    name:"name",
                    url:"url"
                }
			},
			callback: {
				onClick: onClick,
			}
		};
		  zTree = $.fn.zTree.init($("#treeDemo"), setting);   
		  zTree.expandAll(true);
	}
	function onClick(e, treeId, treeNode) {
		var url = treeNode.url.trim();//去首尾空格
	if(url!=null&&url!=undefined&&url!=''){
		var page = parent.window.document.getElementById("rig1");
		 $.addtabs.add({
             id: treeId,
             title: treeNode.name,
             //content: "内容",
             url: treeNode.url,
             ajax: false,
          })
		page.src=treeNode.url;
	}
	}
	 
		$(document).ready(function(){
			createTree();
		});
		
		String.prototype.trim=function(){
			return this.replace(/(^\s*)|(\s*$)/g, "");
			}
	</SCRIPT>
</HEAD>

<BODY>
		<ul id="treeDemo" class="ztree"></ul>
</BODY>
</HTML>